<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

   <input type="text" value="" id="txt1">
   <button id="btn">插入</button>
   <ul></ul>
   <script>
       var oUl = document.getElementsByTagName('ul')[0];
       var btn = document.getElementById('btn');
       var txt1 = document.getElementById('txt1');

       btn.onclick = function () {
          var oLi = document.createElement('li');
          var aLi = document.getElementsByTagName('li');

          oLi.innerHTML = txt1['value'];

          if(aLi.length>0){
              oUl.insertBefore(oLi,aLi[0]);
          }
          else {
              oUl.appendChild(oLi);
          }

       }

   </script>
</body>
</html>